package com.wiener.chamilo.engine.services;


import com.wiener.chamilo.engine.beans.Seccion;
import com.wiener.chamilo.webservices.session.WSServiceBindingStub;
import com.wiener.chamilo.webservices.session.WSServiceLocator;


public class SessionServiceImpl implements Runnable {

	private Seccion session;
	private WSServiceBindingStub binding;

	public SessionServiceImpl(Seccion session) {
		this.session = session;
	}

	public void run() {
		int value = -3;
		System.out.println("crando secciones ");
		try {
			binding = (WSServiceBindingStub) new WSServiceLocator()
					.getWSServicePort();
			binding.setTimeout(60000);
			value = binding.WSSessionCreateSession(session.getSecretKey(), session.getName(), session.getStartDate(), 
					session.getEndDate(), session.getNbDaysAccessBefore(), session.getNbDaysAccessAfter(), session.getNolimit(), session.getVisibility(), session.getUserIdFieldName(), session.getUserIdValue(), session.getSessionIdFieldName(), session.getSessionIdValue(),null);
			System.out.println("crando secciones " + value);
		} catch (Exception e) {
			e.printStackTrace();
			/*BufferedWriter output;
			try {
				File errorFile = new File("C://Chamilo//backup//error//error-"+RAM+".txt");
				output = new BufferedWriter(new FileWriter(
						errorFile));
				output.write(this.alumno.getOriginal_user_id_name());
				output.write(this.alumno.getOriginal_user_id_value());
				if (e instanceof AxisFault) {
					output.write(((AxisFault) e).getFaultString());
				} else {
					output.write(e.getMessage());
				}
				output.close();
			} catch (Exception e1) {
				e1.printStackTrace();
			}*/ 
			

		}

	}
}
